package router

import (
	"github.com/gin-gonic/gin"
	"go-mall/app/client/api"
)

type UserRouter struct{}

func (*UserRouter) ClientUserRouter(publicRouter *gin.RouterGroup, privateRouter *gin.RouterGroup) {
	userApi := api.ClientApi.UserApi
	privateUserRouter := privateRouter.Group("user")
	{
		publicRouter.POST("register", userApi.Register)          // 注册
		publicRouter.POST("login", userApi.Login)                // 登录
		publicRouter.POST("sendEmail", userApi.SendEmail)        // 邮箱验证码
		publicRouter.PUT("resetPassword", userApi.ResetPassword) // 重置用户密码
	}
	{
		privateUserRouter.POST("logout", userApi.Logout)                // 退出登录
		privateUserRouter.GET("getUser", userApi.GetUser)               // 获取用户信息
		privateUserRouter.PUT("setUser", userApi.SetUser)               // 修改用户信息
		privateUserRouter.PUT("changePassword", userApi.ChangePassword) // 修改用户密码
	}
	// 用户地址
	{
		privateUserRouter.GET("addressList", userApi.AddressList)        // 获取用户地址列表
		privateUserRouter.GET("address/:id", userApi.AddressDetails)     // 获取地址详情
		privateUserRouter.GET("address/default", userApi.DefaultAddress) // 获取默认地址
		privateUserRouter.POST("addAddress", userApi.CreateAddress)      // 添加用户地址
		privateUserRouter.PUT("changeAddress", userApi.ChangeAddress)    // 修改用户地址
		privateUserRouter.DELETE("addressDel/id", userApi.DeleteAddress) // 删除用户地址
	}
}
